package com.rsk.dao;

import com.rsk.entity.SysCompanyContacts;
import com.rsk.entity.SysCompanyResponsibles;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.io.Serializable;

@Repository
public interface SysCompanyResponsiblesRepository  extends JpaRepository<SysCompanyResponsibles, Long>,JpaSpecificationExecutor<SysCompanyResponsibles>,Serializable {


    @Modifying
    @Query(value = "update sys_company_responsibles set is_del = 1, operator_user =?2, operator_time = NOW() where id =?1", nativeQuery = true)
    public int delSysSysCompanyResponsibles(Long id, Long operatorUser);

    @Query(value = "select 1 from sys_company_responsibles where id =?1 and is_del = 0", nativeQuery = true)
    public SysCompanyResponsibles selectSysCompanyResponsiblesById(Long id);

    @Modifying
    @Query(value = "update sys_company_responsibles set company_id = ?2, responsible_name =?3, responsible_phone =?4,responsible_post =?5,operator_user =?6,operator_time = NOW() where id =?1", nativeQuery = true)
    public int updateSysSysCompanyResponsibles(Long id, String companyId, String responsibleName, String responsiblePhone,String responsiblePost,Long operatorUser);

}
